import axios from '@/libs/api.request'

export const getRoleList = ({name, pageSize, offset}) => {
  return axios.request({
    url: '/wh-portal/api/role/roleList',
    data: {
      name: name,
    },
    params: {
      limit: pageSize,
      offset: offset
    },
    method: 'post'
  })
};

export const addRole = (menuNode) => {
  return axios.request({
    url: '/wh-portal/api/role/addRole',
    params: {
      menuNode
    },
    method: 'post'
  })
};

export const editRole = (menuNode) => {
  return axios.request({
    url: '/wh-portal/api/role/editRole',
    params: {
      menuNode
    },
    method: 'post'
  })
};

export const getRoleById = ({roleId}) => {
  return axios.request({
    url: '/wh-portal/api/role/getRoleById',
    method: 'post',
    data: {
      roleId: roleId,
    },
  })
};

export const getSysCodeList = () => {
  return axios.request({
    url: '/wh-portal/api/role/getSysCodeList',
    method: 'post'
  })
};

export const getRoleTree = ({roleName, roleId}) => {
  return axios.request({
    url: '/wh-portal/api/role/getRoleTreeList',
    method: 'post',
    params: {
      roleName,
      roleId
    }
  })
};


export const updateRoleNode = (menuNode) => {
  return axios.request({
    url: '/wh-portal/api/role/updateNode',
    params: {
      menuNode
    },
    method: 'post'
  })
};

export const batchDeleteNodes = (ids) => {
  return axios.request({
    url: '/wh-portal/api/role/delete',
    params: {
      ids
    },
    method: 'post'
  })
};





export const  getUserRoleTree = (data)=>{
  return axios.request({
    url: '/wh-portal/api/role/getRoleTreeByUserId',
    data,
    method: 'post'
  })
}


